package com.yaowk.sfp.login.server.service.base;

import com.yaowk.sfp.common.db.BaseServiceImpl;
import java.lang.Long;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.sfp.login.server.service.ILoginLogService;
import com.yaowk.sfp.login.server.dao.LoginLogDao;
import java.lang.String;
import com.yaowk.sfp.login.api.model.LoginLogModel;
import com.yaowk.sfp.login.server.entity.LoginLog;

public abstract class LoginLogServiceBase extends BaseServiceImpl<LoginLogModel, LoginLog, Long> implements ILoginLogService {

	@Autowired
	private LoginLogDao dao;

	@Override protected LoginLogDao getDao() {
	return dao;
	}

	@Override
	public LoginLogModel entity2Model(LoginLog entity) {
		LoginLogModel model = null;
		if(isNotEmpty(entity)){
			model = new LoginLogModel();
			model.setId(entity.getId());
			model.setCreateTime(entity.getCreateTime());
			model.setIp(entity.getIp());
			model.setUserId(entity.getUserId());
		}
		return model;
	}

	@Override
	public LoginLog model2Entity(LoginLogModel model) {
		LoginLog entity = null;
		if(isNotEmpty(model)){
			entity = new LoginLog();
			entity.setId(model.getId());
			entity.setCreateTime(model.getCreateTime());
			entity.setIp(model.getIp());
			entity.setUserId(model.getUserId());
		}
		return entity;
	}

	@Override
	public LoginLog updateParams(LoginLogModel model) {
		LoginLog entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getCreateTime()))
			entity.setCreateTime(model.getCreateTime());
		if(isNotEmpty(model.getIp()))
			entity.setIp(model.getIp());
		if(isNotEmpty(model.getUserId()))
			entity.setUserId(model.getUserId());
		return entity;
	}


}